MC/DC decision coverage part 4: remaining wolfCrypt primitives#10967
Open
danielinux wants to merge 6 commits into
Open
MC/DC decision coverage part 4: remaining wolfCrypt primitives#10967danielinux wants to merge 6 commits into
danielinux wants to merge 6 commits into
Conversation
Add DecisionCoverage/FeatureCoverage tests and tests/unit-mcdc white-box supplements for the remaining reachable wolfCrypt primitive sources in the ISO 26262 per-module MC/DC campaign (excluding asn* and the EVP/OpenSSL compat layer, which are out of the MC/DC boundary). tests/api: - legacy ciphers / digests: des3, camellia, ascon, blake2, siphash - niche PK: srp, eccsi, sakke, hpke - native PQC KEM: frodokem - math: wolfmath tests/unit-mcdc white-box drivers (#include the .c to reach file-static helpers and impl-selected paths, standalone main()/WB_NOTE harness): - blake2b, blake2s - eccsi, sakke, hpke - SP host backends: sp_x86_64, sp_c64, sp_c32 - infra: cryptocb (dev && dev->cb dispatch three-vector, 127/127), logging (per-thread + global error-queue impls, 19/19), memory (static-pool allocator, 46/48) Registrations in tests/api.c, tests/api/include.am and CMakeLists.txt.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the ISO 26262 per-module MC/DC campaign by adding API-level DecisionCoverage/FeatureCoverage tests and standalone tests/unit-mcdc white-box supplements (via #include of the target .c) for additional wolfCrypt primitives and infrastructure modules, and wires the new API tests into the autotools and CMake test builds.
Changes:
- Add multiple
tests/unit-mcdc/*_whitebox.cstandalone drivers to reach file-static helpers and implementation-selected paths for SP math, SAKKE/ECCSI/HPKE, logging, and memory. - Add/extend
tests/apiDecisionCoverage/FeatureCoverage tests for algorithms including SipHash, HPKE, Ascon, BLAKE2, DES (single), FrodoKEM, and wolfmath guards. - Register new API tests in
tests/api.c,tests/api/include.am, andCMakeLists.txt.
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit-mcdc/test_sp_c64_whitebox.c | New white-box supplement to drive sp_c64.c SP math decisions via ECC/RSA/DH entry points. |
| tests/unit-mcdc/test_sakke_whitebox.c | New white-box supplement targeting otherwise-unreachable decisions and file-static helpers in sakke.c. |
| tests/unit-mcdc/test_memory_whitebox.c | New white-box supplement for memory.c static-pool allocator decision coverage. |
| tests/unit-mcdc/test_logging_whitebox.c | New white-box supplement for core logging.c decisions using the per-thread error-queue implementation. |
| tests/unit-mcdc/test_logging_globalq_whitebox.c | New white-box supplement for the global (mutex + list) logging.c error-queue implementation decisions. |
| tests/unit-mcdc/test_hpke_whitebox.c | New white-box supplement to reach inner/static helper NULL-guard decisions in hpke.c. |
| tests/unit-mcdc/test_eccsi_whitebox.c | New white-box supplement to drive static-helper decisions in eccsi.c not reachable via public API alone. |
| tests/unit-mcdc/test_blake2s_whitebox.c | New white-box supplement to exercise internal BLAKE2s init guards unreachable from public wrappers. |
| tests/unit-mcdc/test_blake2b_whitebox.c | New white-box supplement to exercise internal BLAKE2b init guards unreachable from public wrappers. |
| tests/api/test_wolfmath.c | Adds additional decision vectors for mp_rand() and wc_export_int() argument validation. |
| tests/api/test_srp.h | Adds declarations/registration macro for SRP Decision/Feature coverage tests. |
| tests/api/test_siphash.h | Adds declarations/registration macro for SipHash Decision/Feature coverage tests. |
| tests/api/test_siphash.c | New API tests for SipHash DecisionCoverage and FeatureCoverage. |
| tests/api/test_sakke.h | Adds declarations/registration macro for SAKKE Decision/Feature coverage tests. |
| tests/api/test_hpke.h | Adds declarations/registration macro for HPKE Decision/Feature coverage tests. |
| tests/api/test_hpke.c | New API tests for HPKE DecisionCoverage and FeatureCoverage. |
| tests/api/test_frodokem.c | Expands FrodoKEM test comments and adds additional bad-arg vectors for guard operand coverage. |
| tests/api/test_eccsi.h | Adds declarations/registration macro for ECCSI Decision/Feature coverage tests. |
| tests/api/test_des3.h | Registers a new single-DES CBC encrypt/decrypt API test. |
| tests/api/test_des3.c | Adds a new test covering single-DES guard decisions and a basic round-trip. |
| tests/api/test_camellia.c | Adds missing bad-arg operand coverage for wc_CamelliaSetKey() guard. |
| tests/api/test_blake2.h | Registers new decision-coverage tests for BLAKE2b/BLAKE2s wrappers. |
| tests/api/test_blake2.c | Adds DecisionCoverage tests for wrapper-level bound checks (internal guards remain in white-box tests). |
| tests/api/test_ascon.h | Registers a new Ascon decision-coverage test. |
| tests/api/test_ascon.c | Adds Ascon DecisionCoverage tests covering argument/state guard decisions across hash and AEAD APIs. |
| tests/api/include.am | Adds new API test sources/headers to autotools test build lists. |
| tests/api.c | Includes and registers the new API test groups in the master test case list. |
| CMakeLists.txt | Adds new API test sources to the CMake tests target sources list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- test_hpke.c: guard both test bodies on HAVE_HPKE. They were gated only on
HAVE_CURVE25519 && !NO_SHA256 && WOLFSSL_AES_128, so configs with those but
without HPKE (e.g. pk-mlkem) compiled the body against absent HPKE symbols
and failed to build under -Werror.
- test_sakke.c: make the wc_GenerateSakkeRskTable / wc_GenerateSakkePointITable
/ wc_SetSakkePointITable checks SP-backend agnostic. The required table size
is 0 on the small-stack SP path but non-zero on the full precomputation path
(sizeof(sp_table_entry_1024) * 1167 / * 256), so the previous fixed
"len == 0" and success-with-tiny-buffer assertions failed (and could write a
full-size table into the small stack buffer) under --enable-all. Capture the
queried length and branch: the Rsk table builds into a correctly-sized heap
buffer; the PointI table's full-path build/store is left to the sakke_test
KAT (it stores the pointer in the key).
- codespell: rename addRes -> addResult in test_sakke_whitebox.c and reword a
comment in test_hpke.c ("statics").
- test_wolfmath.c: limit the "digits > capacity" mp_rand rejection vector to the fixed-size backends. USE_INTEGER_HEAP_MATH grows the mp_int via mp_set_bit instead of rejecting, so the call would legally succeed (and force a large allocation), failing ExpectIntNE. - test_memory_whitebox.c: guard the WOLFSSL_STATIC_MEMORY / WOLFSSL_MEM_FAIL_COUNT defines with #ifndef so a build that already provides them (user_settings.h / CFLAGS) does not hit a redefinition warning treated as error. - test_sakke_whitebox.c: skip the sakke_mulmod_base_add() calls when wc_ecc_new_point() returns NULL. That function does not validate its result pointer and would dereference a NULL addResult under allocation pressure.
wc_ValidateEccsiPair() reports an off-curve PVT via wc_ecc_is_point(), whose error code is backend-dependent: the mp-based check (classic / SP_MATH_ALL / fast-math) returns IS_POINT_E, but the minimal WOLFSSL_SP_MATH backend routes through sp_ecc_is_point_*(), which returns MP_VAL for a point not on the curve (and eccsi.c only remaps -1 -> IS_POINT_E, not MP_VAL). Select the expected code per backend so the all-pq-sp-math CI config (--enable-sp-math) passes. Verified: full unit.test --api under --enable-all --enable-sp-math --enable-sp-asm reports 0 failures.
The tests/unit-mcdc/*.c MC/DC white-box supplements this branch adds each #include a wolfCrypt .c and carry their own main(); they are built standalone by the per-module coverage campaign and are NOT compiled into libwolfssl or unit.test (that would duplicate main()/symbols). They are test-only. The source-completeness check (per-PR diff) requires every file a PR adds to appear in an include.am. Since these cannot be tests_unit_test_SOURCES, list them in EXTRA_DIST -- the same bucket tests/api/include.am uses for its non-compiled files -- so they ship in the dist tarball without being built. Scope: only the white-boxes this branch introduces.
Add the tests/unit-mcdc white-box drivers produced by the coverage campaign's fault-injection and SP-ARM emulator-lane passes, and extend the EXTRA_DIST listing to cover them (test-only; standalone main() + #include the target .c; never built into libwolfssl or unit.test -- see the comment in tests/include.am). Fault-injection (mcdc_fault_alloc.h: a fail-after-N wolfSSL_SetAllocators mock, swept across allocation sites to drive the FALSE half of (err==MP_OKAY)&&step success-chain guards): dsa, eccsi, sakke, hpke, mlkem, mldsa, integer, rsa, frodokem (+ a shared frodokem fault header). SP-ARM emulator lanes (drive the C-level decisions in the cross-only asm SP backends under qemu-user / m33mu): sp_arm64, sp_arm32, sp_armthumb, sp_cortexm.
danielinux
force-pushed
the
mcdc-test-coverage
branch
from
July 22, 2026 16:17
d4d8029 to
725bd2c
Compare
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add DecisionCoverage/FeatureCoverage tests and tests/unit-mcdc white-box supplements for the remaining reachable wolfCrypt primitive sources in the ISO 26262 per-module MC/DC campaign (excluding asn* and the EVP/OpenSSL compat layer, which are mot yet covered).
tests/api:
tests/unit-mcdc white-box drivers (#include the .c to reach file-static helpers and impl-selected paths, standalone main()/WB_NOTE harness):
Registrations in tests/api.c, tests/api/include.am and CMakeLists.txt.